﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace WebAPITest.Controllers
{
    public class ValuesController : ApiController
    {
        // GET api/values
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/values
        [HttpPost]
        public object PostMethod([FromBody]IllegalDataModel value)
        {
            //int s = int.Parse(value.kkbh2);
            string val = JsonConvert.SerializeObject(value);
            Console.WriteLine(val);

            ReturnDataModel model = new ReturnDataModel();
            model.code = "200";
            model.message = "操作成功";
            
            return model;
        }

        [HttpPut]
        public object PtMethod([FromBody]AlxaillegalModel value,string v1)
        {
            //int s = int.Parse(value.kkbh2);
            string val = JsonConvert.SerializeObject(value);
            Console.WriteLine(val);

            AlxaReturnDataModel model = new AlxaReturnDataModel();
            model.error_code = "0000000000";
            model.message = "ok";

            return model;
        }

        [HttpPost]
        public string Method2(string str1,string str2)
        {
            ReturnDataModel model = new ReturnDataModel();
            model.code = "200";
            model.message = "操作成功";

            return "200";
        }

        // PUT api/values/5
        //public void Put(int id, [FromBody]string value)
        //{
        //}
        [HttpPut]
        public object Put([FromBody]AlxaillegalModel value)
        {
            string val = JsonConvert.SerializeObject(value);
            Console.WriteLine(val);

            AlxaReturnDataModel model = new AlxaReturnDataModel();
            model.error_code = "0000000000";
            model.message = "ok";
            return model;
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }
}
